﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using becom.Model;
namespace becom.BLL
{
	/// <summary>
	/// oa_quipment_maintenance
	/// </summary>
	public partial class oa_quipment_maintenance
	{
		private readonly becom.DAL.oa_quipment_maintenance dal=new becom.DAL.oa_quipment_maintenance();
		public oa_quipment_maintenance()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int ID)
		{
			return dal.Exists(ID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(becom.Model.oa_quipment_maintenance model)
		{
			dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(becom.Model.oa_quipment_maintenance model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int ID)
		{
			
			return dal.Delete(ID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string IDlist )
		{
			return dal.DeleteList(IDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public becom.Model.oa_quipment_maintenance GetModel(int ID)
		{
			
			return dal.GetModel(ID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public becom.Model.oa_quipment_maintenance GetModelByCache(int ID)
		{
			
			string CacheKey = "oa_quipment_maintenanceModel-" + ID;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(ID);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (becom.Model.oa_quipment_maintenance)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<becom.Model.oa_quipment_maintenance> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<becom.Model.oa_quipment_maintenance> DataTableToList(DataTable dt)
		{
			List<becom.Model.oa_quipment_maintenance> modelList = new List<becom.Model.oa_quipment_maintenance>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				becom.Model.oa_quipment_maintenance model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new becom.Model.oa_quipment_maintenance();
					if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="")
					{
						model.ID=int.Parse(dt.Rows[n]["ID"].ToString());
					}
					if(dt.Rows[n]["RepairDate"]!=null && dt.Rows[n]["RepairDate"].ToString()!="")
					{
						model.RepairDate=DateTime.Parse(dt.Rows[n]["RepairDate"].ToString());
					}
					if(dt.Rows[n]["RepairPeople"]!=null && dt.Rows[n]["RepairPeople"].ToString()!="")
					{
					model.RepairPeople=dt.Rows[n]["RepairPeople"].ToString();
					}
					if(dt.Rows[n]["FaultCode"]!=null && dt.Rows[n]["FaultCode"].ToString()!="")
					{
					model.FaultCode=dt.Rows[n]["FaultCode"].ToString();
					}
					if(dt.Rows[n]["FaultInfo"]!=null && dt.Rows[n]["FaultInfo"].ToString()!="")
					{
					model.FaultInfo=dt.Rows[n]["FaultInfo"].ToString();
					}
					if(dt.Rows[n]["ReceiverPeople"]!=null && dt.Rows[n]["ReceiverPeople"].ToString()!="")
					{
					model.ReceiverPeople=dt.Rows[n]["ReceiverPeople"].ToString();
					}
					if(dt.Rows[n]["IsSMS"]!=null && dt.Rows[n]["IsSMS"].ToString()!="")
					{
						model.IsSMS=int.Parse(dt.Rows[n]["IsSMS"].ToString());
					}
					if(dt.Rows[n]["HandlePeople"]!=null && dt.Rows[n]["HandlePeople"].ToString()!="")
					{
					model.HandlePeople=dt.Rows[n]["HandlePeople"].ToString();
					}
					if(dt.Rows[n]["HandleResult"]!=null && dt.Rows[n]["HandleResult"].ToString()!="")
					{
						model.HandleResult=int.Parse(dt.Rows[n]["HandleResult"].ToString());
					}
					if(dt.Rows[n]["ResultDate"]!=null && dt.Rows[n]["ResultDate"].ToString()!="")
					{
						model.ResultDate=DateTime.Parse(dt.Rows[n]["ResultDate"].ToString());
					}
					if(dt.Rows[n]["ResultInfo"]!=null && dt.Rows[n]["ResultInfo"].ToString()!="")
					{
					model.ResultInfo=dt.Rows[n]["ResultInfo"].ToString();
					}
					if(dt.Rows[n]["CreatePeopleCode"]!=null && dt.Rows[n]["CreatePeopleCode"].ToString()!="")
					{
					model.CreatePeopleCode=dt.Rows[n]["CreatePeopleCode"].ToString();
					}
					if(dt.Rows[n]["CreateDate"]!=null && dt.Rows[n]["CreateDate"].ToString()!="")
					{
						model.CreateDate=DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

